<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/hallimport.jsp" %>
<link href="${ctx}/css/hall.css" rel="stylesheet">
<link href="${ctx}/css/web_style.css" rel="stylesheet">
<title>采购活动-采购大厅</title>
</head>
<body>
<body>
<%@ include file="/common/halltop_caigou.jsp" %>
<!---content start-->
  <div  id="content" class="fixedw">
    <div class="tzgg">
       <h6 class="tzgg_title"><img src="${ctx}/images/icon05.png" /> 采购公告</h6>
       <form	id="content_notice_form">
  		<input type="hidden" name="methodKey" value="contentList" >
  		<input type="hidden" name="contentType" value="采购公告" >
  		<input type="hidden" name="tab" value="div" >
  	</form>
       <marquee width="780"><ul id="content_notice_div"></ul></marquee>
	    <script type="text/template" id="content_notice_div_html">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<li><a href="/admin/hall/content/<?=rows[i].infoId?>"><?=rows[i].title?></a></li>
		<?}?> 
		</script>
       <div class="user"> 当前用户：${loginUser.userEname} <a href="javascript:logout()"><img src="${ctx}/images/web/icon_tc.png"  /></a> </div>
    <p class="more"><a href="${ctx}/sendPage/hall/caigou-contents">查看更多</a></p>
    </div>
    <div class="main">
       <div class="left">
	    <!-- 左侧竞价活动 -->
	    <h5 class="con_title"><span></span> 采购活动</h5>
	    	<form id="sessionList_form">
				<input type="hidden" name="page"  value="1">
				<input type="hidden" name="rows"  value="5">
				<input type="hidden" name="status"  value="2">
				<input type="hidden" name="methodKey"  value="sessionList">
				<input type="hidden" name="direction"  value="F">
			</form>
		<div class="hall_box"  id="sessionList_div"></div>
		<div id="sessionList_page" class="web_pages"></div>
		<script type="text/template" id="sessionList_div_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<dl>
		<input type="hidden" name="seIids" value="<?=rows[i].sessionId?>" />
			<dt><a href="${ctx}/admin/hall/session/<?=rows[i].sessionId?>"><img src="<?=strUtil.doNull(rows[i].picUrl,'${ctx}/images/def.jpg')?>"/></a></dt>
			<dd>
                <div class="halltitle_box">
                  <div class="hall_l">
					<h5><a title="<?=rows[i].sessionName?>" href="${ctx}/admin/hall/session/<?=rows[i].sessionId?>"><?=strUtil.subStr(rows[i].sessionName,15)?></a></h5>
					<p><?=strUtil.subStr(rows[i].pub.infoDesc,100)?></p>
			        <p class="jxz">
						<span><?=sessionStatusText(rows[i].status)?></span>
						<em>开始时间：<?=strUtil.doNull(rows[i].openTime,'')?></em>
					</p>
                    <p class="jxz" style="font-size:14px;">
						当前有<B style="color:red;font-size:20px;" id="session_itemNum_<?=rows[i].sessionId?>"></B>个标的正在竞价
					</p>
			      </div>                  
                  <div class="hall_r">
                     <h4><span class="sesbrows" id="session_browsing_<?=rows[i].sessionId?>">0</span></h4>
                     <p>次浏览</p>
                  </div>
                </div>
              </dd>
		</dl>
   <?}?>  		
</script>
		
	</div>
	<!-- 右侧标的列表 -->
	<div class="right">
      <h5 class="con_title"><span></span> 推荐的标的</h5>
      <form id="proList_form">
		<input type="hidden" name="page"  value="1">
		<input type="hidden" name="rows"  value="7" id="rows">
		<input type="hidden" name="direction"  value="F">
		<input type="hidden" name="methodKey"  value="itemList">
		<input type="hidden" name="tag"  value="div">
		<input type="hidden" name="itemStatus"  value="2" />
	</form>
    <div class="tj_box" id="proList_div"></div>
    <script type="text/template" id="proList_div_html">
	  <? for ( var i = 0; i < rows.length; i++) {?>
		 <dl><input type=hidden name=ids value=<?=rows[i].itemId?> >
			<dt><a href="${ctx}/admin/hall/session/<?=rows[i].sessionId?>"><img src="<?=strUtil.doNull(rows[i].picUrl,'${ctx}/images/def.jpg')?>"/></a></dt>
			<dd>
				<h5><a onclick="gotohall('<?=rows[i].itemId?>');"><?=strUtil.subStr(rows[i].itemName,11)?></a></h5>
				<p>当前价：<span id=value_<?=rows[i].itemId?>></span>万</p>
			    <p>距结束：<span id=sptime_<?=rows[i].itemId?>></span></p>
            </dd>
		 </dl>
     <?}?>  		
	</script>
    </div>
	</div>
</div>	
<%@ include file="/common/hallbottom.jsp" %>
</body>
</html>

<script>
var itermIds = "";
//打开查看页面
function gotohall(itemId){
	//alert(sessionId);
	window.location.href= ctx+spaceDomain+"hall/item/"+itemId;
}

//查询提交
function runningListSearch(){
	searchSubmit("hall","proList");
}

//查询session提交
function sessionListSearch(){
	searchSubmit("hall","sessionList");
	
}

function getIds(){
	var itermIds = "";
	$("input[name='ids']").each(function(){
		itermIds += $(this).val()+",";
	});	
	return itermIds;
}

function myLoad(){
	var itermIds =getIds(); 
	$.ajax({
		   type:'get',
		   url:ctx+spaceDomain+'hall/cacheList',
		   data:{ids:itermIds},
		   dataType:'json',
		   success: function(myData){
			   //alert(myData.total);
			   if(myData.total>0){
			     myData.rows.forEach(function(e){
			    	 $("#value_"+e.itemId).html(e.lastValue) ;
			    	 $("#num_"+e.itemId).html(e.bidTimes) ;
			    	 $("#user_"+e.itemId).html(e.userName) ;
			    	 $("#status_"+e.itemId).html(itemStatusTxt(e.status)) ;
				     $("#sptime_"+e.itemId).html(spareTxt(e.spareTime)) ;
				 });  
			   }
		  }
	});	
}

//初始化加载
$(function(){
	//加载分页列表
	sessionListSearch();
	runningListSearch();
	//myLoad();
	setInterval(myLoad,3000);
	//加载所有采购公告
	searchSubmit("hall","content_notice");
	
});

function loadSessionBorws(){
	var seIds = "";
	$("input[name='seIids']").each(function(){
		seIds += $(this).val()+",";
	});
	//alert(seIds);
	var this_url = ctx+spaceDomain+"hall/sessionBrowsing";
	$.ajax({
		   type:'get',
		   url:this_url,
		   data:{"sessionIdList":seIds},
		   dataType:'json',
		   success: function(myData){
			  // alert(myData.flag +"="+myData.rows);
			   if("T"==myData.flag){
				   var rowsdata = myData.rows;
				   for(var k in  rowsdata){
					   var obj = jQuery.parseJSON(rowsdata[k]);
					   $("#session_browsing_"+k).text(obj.browsing);
					   $("#session_itemNum_"+k).text(obj.itemNum);
				   }
			   }
		  }
	});	
}

</script>

